﻿@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section styles{
    <style>
      
    </style>

}

<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form form-search" action="">
            <div class="layui-form-item">
                <label class="layui-form-label">控制器</label>
                <div class="layui-input-inline">
                    <input type="text" name="controllerName" placeholder="请输入控制器" autocomplete="off" class="layui-input">
                </div>
                <label class="layui-form-label">日期范围</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="createtime" name="createtime" placeholder="请选择开始日期范围" >
                </div>
                
                <button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="operatelog-query">
                    <i class="layui-icon layui-icon-search"></i>
                    查询
                </button>
                <button type="reset" class="pear-btn pear-btn-md">
                    <i class="layui-icon layui-icon-refresh"></i>
                    重置
                </button>
            </div>
        </form>
    </div>
</div>
<div class="layui-card">
    <div class="layui-card-body">
        <table id="operatelog-table" lay-filter="operatelog-table"></table>
    </div>
</div>

<script type="text/html" id="loginlog-executionTime">
    {{layui.util.toDateString(d.executionTime, 'yyyy-MM-dd HH:mm:ss')}}
</script>
<script type="text/html" id="log-bar">
    {{#if (d.operateState == 1) { }}
     <span class="layui-badge-dot layui-bg-green"></span>
    {{# }else if(d.operateState ==0){ }}
    <span class="layui-badge-dot"></span>
    {{# } }}
</script>
@section scripts{
    <script>

        layui.use(['lscom', 'laydate', 'form', 'table'], function () {
            var $ = layui.$;
            var lscom = layui.lscom;
            var laydate = layui.laydate;
            var form = layui.form;
            var table = layui.table;

            //开始日期
            laydate.render({
                elem: '#createtime',
                range: true
            });

            form.render();

            form.on('submit(operatelog-query)', function(data){
                table.reload('operatelog-table', {
                    where: data.field,
                    page: {
                        curr: 1
                    }
                })
		        return false;
		    });

		    table.render({
                elem: '#operatelog-table',
                url: "/Systems/OperateLogs/GetAllLogs",
                page: true,
                height: 'full-150',
		        cols: [
                    [
                        { title: '状态', field: 'operateState', align: 'center', width: 60, templet: "#log-bar" },
                        { title: '控制器', field: 'controllerName', align: 'center', width: 150 },
                        { title: '方法', field: 'actionName', align: 'center', width: 150 },
                        { title: 'IP', field: 'operateIp', align: 'center', width: 150 },
                        { title: '参数', field: 'parameter', align: 'center' },
                        { title: '耗时(毫秒)', field: 'consumedTime', align: 'center', width: 120 },
                        { title: '操作人', field: 'createBy', align: 'center', width: 120 },
                        { title: '操作时间', field: 'createDate', align: 'center', width: 180 },
		            ]
		        ],
		        skin: 'line',
		        toolbar: 'true',
		        defaultToolbar: [{
		            layEvent: 'refresh',
		            icon: 'layui-icon-refresh',
		        }, 'filter', 'print', 'exports']
            });

            table.on('toolbar(operatelog-table)', function(obj){
                if (obj.event === 'refresh'){
		            window.refresh();
		        }
		    });

            window.refresh = function(){
                table.reload('operatelog-table');
		    }
        });
    </script>
}

